# coding=UTF-8
'''
Created on 2018年4月26日

采集主页面元素
@author: lijie
'''
from businessLayer.page_element.element_base import ElementBase

class MetaCollectionPage():
        
    def coll_list_ancestor(self,name): 
        '''获取采集list祖级xpath,
        arg: str name,采集名称
        '''
        _xpath=''  
        _xpath="//div[@class='list-head']//span[contains(.,'"+name+"')]/ancestor::div[@class='tableList-item']"  
        return _xpath

    class BtnAddCollection(ElementBase):
        '''新增采集按钮
        '''
        def __init__(self):
            ElementBase("//button[.='新增采集']")
            
            
    # 采集list元素定位-----------------------------------------------------------------------------------------------            
    class LblCollTitleByName(ElementBase):
        '''元数据采集list页面，元素采集标题标签，通过标题名称定位标题标签
        arg: str name,标题名称
        '''
        def __init__(self,name):
            ElementBase("//div[@class='list-head']//span[contains(.,'"+name+"')]")
            
    class LblStatusByTitle(ElementBase):
        '''采集提交状态标签
        '''
        def __init__(self,title):
            ElementBase(self.coll_list_ancestor(title)+"//span[contains(.,'提交状态')]/following-sibling::span/span")
            
    class LblCreateDTByTitle(ElementBase):
        '''采集创建时间标签
        '''
        def __init__(self,title):
            ElementBase(self.coll_list_ancestor(title)+"//span[contains(.,'创建时间')]/following-sibling::span")
            
    class LblServiceIPByTitle(ElementBase):
        '''采集服务器地址标签
        '''
        def __init__(self,title):
            ElementBase(self.coll_list_ancestor(title)+"//span[contains(.,'服务地址')]/following-sibling::span")
    
    class BtnEditByTitle(ElementBase):
        '''采集编辑按钮
        '''
        def __init__(self,title):
            ElementBase(self.coll_list_ancestor(title)+"//i[@class='el-icon-c-edit']/parent::span") 
            
    class BtnDeleteByTitle(ElementBase):
        '''采集删除按钮
        '''
        def __init__(self,title):
            ElementBase(self.coll_list_ancestor(title)+"//i[@class='el-icon-c-delete']/parent::span") 
    #-------------------------------------------------------------------------------------------------------------------- 
    
    class BtnSearchByStatus(ElementBase):
        '''提交状态分类查询按钮
        arg: str sta,全部，草稿，已提交
        ''' 
        def __init__(self,sta):
            ElementBase("//div[contains(.,'提交状态')]//a[.='"+sta+"']")      
            
    class TxtNameSearch(ElementBase):
        '''任务名称、数据源名称查询输入框
        ''' 
        def __init__(self):
            ElementBase("//input[@name='searchLable']")
            
    class BtnNameSearch(ElementBase):
        '''任务名称、数据源名称查询按钮
        ''' 
        def __init__(self):
            ElementBase("//a[@class='searchBtn']")         
